﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;


namespace Snake
{
    class GameEngine
    {
        private int _speed{get; set;}

        public GameEngine()
        {
            _speed = 500;
        }

        public event EventHandler Tick;

        public void Start()
        {
            for (; ; )
            {
                Thread.Sleep(_speed);
                OnTick();
                Console.Beep();
            }
        }

        protected virtual void OnTick()
        {
            if (this.Tick != null)
            this.Tick(this, null);
        }

        public void ChangeSpeed(int newSpeed)
        {
            _speed = newSpeed;
        }
 
        


    }
}
